package com.bright.hxj.cwduijie.service.impl;

import com.bright.hxj.cwduijie.enums.DataApi;
import com.bright.hxj.cwduijie.pojo.bo.ApiDataCollection;
import com.bright.hxj.cwduijie.pojo.po.IncomeDistribution;
import com.bright.hxj.cwduijie.pojo.query.DuijieQuery;
import com.bright.hxj.cwduijie.repository.IncomeDistributionRepository;
import com.bright.hxj.cwduijie.service.AbstractMonthlyReportApiService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

/**
 * @Author hxj
 * @Date 2025/2/19 17:47
 * @Description
 */
@Component
@RequiredArgsConstructor
public class ApiIncomeDistributionServiceImpl extends AbstractMonthlyReportApiService<IncomeDistribution, IncomeDistribution> {

    private final IncomeDistributionRepository repo;

    @Override
    protected void getData(ApiDataCollection apiDataCollection, DuijieQuery duijieQuery) {
        apiDataCollection.setIncomeDistributionMap(Collections.singletonMap("", getNeedDuijieData(duijieQuery)));
    }

    @Override
    public JpaSpecificationExecutor getJpaSpecificationExecutor() {
        return repo;
    }

    @Override
    public DataApi getDataApi() {
        return DataApi.INCOME_DISTRIBUTION;
    }

    @Override
    public Function<IncomeDistribution, Integer> getIdFunc() {
        return IncomeDistribution::getId;
    }

    @Override
    public Function<ApiDataCollection, Map<String, List<IncomeDistribution>>> getDataFunc() {
        return ApiDataCollection::getIncomeDistributionMap;
    }

    @Override
    public Function<IncomeDistribution, IncomeDistribution> getConverterFunc() {
        return Function.identity();
    }

}
